//
//  PKRegisterViewController.swift
//  GoAbroad
//
//  Created by Pink Snow on 2025/5/14.
//

import UIKit

class PKRegisterViewController: PKBaseViewController {
    private let emailTextField = UITextField()
    private let passwordTextField = UITextField()
    private var backButton = UIButton(type: .custom)
    private var registerButton = UIButton(type: .custom)
    override func setupUI() {
        view.backgroundColor = .white
        title = "测试"
        backButton.setImage(.init(named: "back"), for: .normal)
        view.addSubview(backButton)
        emailTextField.tintColor = .black
        passwordTextField.tintColor = .black
 
        
        backButton.rx.tap.subscribe { _ in
            self.navigationController?.popViewController(animated: true)
        }.disposed(by: rx.disposeBag)
        
        
        
        
        let titleLabel = UILabel()
        titleLabel.text = "Sign in to your account"
        titleLabel.font = UIFont.systemFont(ofSize: 22, weight: .semibold)
        titleLabel.textAlignment = .center
        emailTextField.placeholder = "Email address"
        emailTextField.borderStyle = .roundedRect
        emailTextField.keyboardType = .emailAddress
        
        passwordTextField.placeholder = "Password"
        passwordTextField.borderStyle = .roundedRect
        passwordTextField.isSecureTextEntry = true
        
        registerButton = .create(title: "Register")
//        registerButton = normalButton(.custom,"Continue", .normal, 16, 8, .black, .white, true)
        
//        googleLoginButton.setImage(.init(named: "google"), for: .normal)
//        googleLoginButton.setTitle("Sign in Google", for: .normal)
//        googleLoginButton.setTitleColor(.black, for: .normal)
//        googleLoginButton.layer.borderColor = UIColor.black.cgColor
//        googleLoginButton.layer.borderWidth = 2
//        googleLoginButton.layer.cornerRadius = 5
//        googleLoginButton.clipsToBounds  = true
        
        view.addSubview(emailTextField)
        view.addSubview(passwordTextField)
//        view.addSubview(loginButton)
        view.addSubview(titleLabel)
        view.addSubview(registerButton)
//        view.addSubview(googleLoginButton)
//
//        googleLoginButton.rx.controlEvent(.touchUpInside).subscribe { _ in
//            GIDSignIn.sharedInstance.signIn(withPresenting: self) { signin ,error in
//                guard  error == nil else { return }
//            }
//        }.disposed(by: rx.disposeBag)

        
        
        
        backButton.snp.makeConstraints { make in
            make.left.equalTo(ScreenAdapter.x(20))
            make.top.equalTo(DeviceHelper.navigationBarHeight + 20)
            make.width.height.equalTo(ScreenAdapter.x(30))
        }
        titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(view.snp.centerY).offset(-200)
            make.centerX.equalToSuperview()
        }
        emailTextField.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(ScreenAdapter.x(-50))
            make.left.equalTo(ScreenAdapter.x(50))
            make.right.equalTo(-ScreenAdapter.x(50))
            make.height.equalTo(ScreenAdapter.x(44))
        }
        passwordTextField.snp.makeConstraints { make in
            make.top.equalTo(emailTextField.snp.bottom).offset(20)
            make.leading.equalTo(emailTextField)
            make.trailing.equalTo(emailTextField)
            make.height.equalTo(emailTextField.snp.height)
        }
        registerButton.snp.makeConstraints { make in
            make.top.equalTo(passwordTextField.snp.bottom).offset(80)
            make.leading.equalTo(emailTextField)
            make.trailing.equalTo(emailTextField)
            make.height.equalTo(emailTextField.snp.height)
        }
//        googleLoginButton.snp.makeConstraints { make in
//            make.top.equalTo(loginButton.snp.bottom).offset(20)
//            make.left.equalTo(ScreenAdapter.x(50))
//            make.width.equalTo(loginButton)
//            make.height.equalTo(ScreenAdapter.x(44))
//        }
    }
    
    override func bindEvents() {
    
    }
    override func bindViewModel() {
        
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
